package operation;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yang
 * Date: 2022-05-19
 * Time: 19:16
 */
public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入借阅的书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        boolean flag  = false;
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(name.equals(bookList.getBook(i).getName())){
                bookList.getBook(i).setState(true);
                System.out.println("借阅成功");
                flag = true;
                break;
            }
        }
        if(flag == false){
            System.out.println("查无此书");
        }
    }
}
